class CommandTask:
    def __init__(self, target, args, delay=0):
        self.target = target
        self.args = args
        self.complete = False
        self.delay = delay

    def Do(self):
        self.target(self.args)
        if self.delay:
            import time
            time.sleep(self.delay)
            self.complete = True
        else:
            self.complete = True


class CommandList:
    def __init__(self):
        self.list_task = []
        self.current_index = 0
        self.current: [CommandTask] = None
        self.complete = False

    def AddCommand(self, todo):
        self.list_task += todo

    def _Do(self):
        self.current = self.list_task[self.current_index]
        self.current.Do()
        if self.current.complete:
            self.current_index += 1

    def Run(self):
        while self.current_index <= len(self.list_task) - 1:
            self._Do()
        else:
            self.current_index = len(self.list_task) - 1
            self.complete = True


def task_1(args):
    print(args)


if __name__ == '__main__':
    todo_list = CommandList()
    todo_list.AddCommand([CommandTask(task_1, {"a": 12}, 1)])
    todo_list.AddCommand([CommandTask(task_1, {"a": 34}, 2)])
    todo_list.AddCommand([CommandTask(task_1, {"a": 56}, 3), CommandTask(task_1, {"a": 78}, 4)])
    todo_list.Run()
